
global user "`c(username)'"
global dirdata "C:\Users\\$user\Dropbox\CCT BJP\data"
global dir1  "$dirdata\Final data"
global dir2  "$dirdata\Results\graphs"
global dir3  "$dirdata\Results\"
cd "$dir3"

use "$dir1\pooled_hh_privado.dta", clear
keep if tau>=-4  
keep if min_schooling>=1 & min_schooling<9

g age=age_m if hhmale==0
replace age=age_p if hhmale==1
g spanish=spanish_m if hhmale==0
replace spanish=spanish_p if hhmale==1


g Post=tau>=0
egen w_hoursw_head=rowtotal(w_hoursw_p w_hoursw_m)
g work_head=w_hoursw_head>0
replace work_head=. if work_m==. & work_p==. 
egen w_ylabor_head=rowtotal(w_ylabor_p w_ylabor_m)
replace w_hoursw_p=. if work_p==.
replace w_hoursw_m=. if work_m==.

global covs "age c.age  spanish schooling schooling hhmale  urban np nchild5  hhmale age_sac c.age_sac#i.year  i.departamento#i.year i.year"


local replace replace
foreach x in work_head w_hoursw_head nwork w_hoursw_t work_m  w_hoursw_m work_p w_hoursw_p {

sum `x' if tau==-1 
local mean_dv=r(mean)
areg  `x'  Post i.min_schooling $covs [w=factor] if (min_schooling>=1 & min_schooling<9) , a(departamento) cluster(municipio) 
outreg2 using "$dir3\PRobust_placebo", excel `replace' ctitle(``x'_lab') keep(Post) less(0) nocons  bdec(3) adds(Clusters, e(N_clust), Mean DV, `mean_dv') alpha(0.01, 0.05, 0.1) addtext(Sample, 1st-8th, Group linear trends, YES, Region X year FE, NO)
local replace append
}
